﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SL.Library.Framework
{
    public class Result
    {
        public enum StatusEnum
        {
            Success,
            Warn,
            Fault
        }

        public StatusEnum Status { get; set; }
        public object Data { get; set; }
        public string Infomation { get; set; }
        public Exception Exception { get; set; }

        public static Result Succeed()
        {
            var result = new Result();
            result.Status = StatusEnum.Success;

            return result;
        }

        public static Result Succeed(object data)
        {
            var result = new Result();
            result.Status = StatusEnum.Success;
            result.Data = data;
            return result;
        }

        public static Result Warn(string info)
        {
            var result = new Result();
            result.Status = StatusEnum.Warn;
            result.Infomation = info;
            return result;
        }

        public static Result Warn(string info, object data)
        {
            var result = new Result();
            result.Status = StatusEnum.Warn;
            result.Infomation = info;
            result.Data = data;
            return result;
        }

        public static Result Warn(string info, object data, Exception exception)
        {
            var result = new Result();
            result.Status = StatusEnum.Warn;
            result.Infomation = info; 
            result.Data = data;
            result.Exception = exception;
            return result;
        }

        public static Result Fault(string info)
        {
            var result = new Result();
            result.Status = StatusEnum.Fault;
            result.Infomation = info;
            return result;
        }

        public static Result Fault(string info, Exception exception)
        {
            var result = new Result();
            result.Status = StatusEnum.Fault;
            result.Infomation = info;
            result.Exception = exception;
            return result;
        }
    }
}
